package com.servlet.kind;

import com.alibaba.fastjson.JSONObject;
import com.enitiy.Kind;
import com.service.kind.KindServiceImpl;
import com.utils.model.Model;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 创建作者 ：MySunshine
 * 创建时间 2022/10/24 16:49
 * 项目名称 SHUSHAN
 */
@WebServlet("/KindSelectAllByDba")
public class KindSelectAllBydba extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        KindServiceImpl ksi = new KindServiceImpl();
        List<Kind> kinds = ksi.kindSelectAll();
        System.out.println(kinds);
        Model model = new Model();
        if (kinds!=null&&kinds.size()!=0){
                 model.setCode(0);
                 model.setData(kinds);
                 model.setMsg("select  is  good!");
        }else {
            model.setMsg("select  is  not!");
        }
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().print(JSONObject.toJSON(model));
    }
}
